let data = { type: 3, role: "admin" };

let { type, role } = data;

let actions = () => {
  function admin() {
    console.log("admin");
  }
  function guest() {
    console.log("guest");
  }

  function adminOther() {
    console.log("adminOther");
  }
  return new Map([
    [/^admin_[1-4]$/, admin],
    [/^guest_[1-4]$/, guest],
    [/^admin.*/, adminOther],
  ]);
};
let buttonEvent = (type, role) => {
  // console.log(actions());
  [...actions()]
    .filter(([reg]) => {
      // console.log(reg);
      return reg.test(`${role}_${type}`);
    })
    .forEach(([_, v]) => {
      v();
    });
};

buttonEvent(type, role);
